package com.zhuhjay.eduservice.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.zhuhjay.eduservice.entity.EduTeacher;
import com.zhuhjay.eduservice.mapper.EduTeacherMapper;
import com.zhuhjay.eduservice.service.EduTeacherService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 讲师 服务实现类
 * </p>
 *
 * @author ZhuHJay
 * @since 2022-09-06
 */
@Service
public class EduTeacherServiceImpl extends ServiceImpl<EduTeacherMapper, EduTeacher> implements EduTeacherService {

    @Override
    @Cacheable(value = "TEACHER", key = "'LIMIT 4'")
    public List<EduTeacher> getTeacherLimitList() {
        return this.list(new LambdaQueryWrapper<EduTeacher>()
                .orderByDesc(EduTeacher::getId).last("limit 4"));
    }
}
